def search_first(nums,target):
    n=len(nums)
    if n==0 or nums[0]>target: return -1
    if nums[0]==target: return 0
    i,j=0,n-1 
    while j>i+1:
        mid=(i+j)//2
        if nums[mid]>=target: j=mid 
        else: i=mid
    if nums[j]==target: return j
    else: return -1

def search_last(nums,target,first):
    if first==-1: return -1 
    n=len(nums)
    if nums[n-1]<target: return -1
    if nums[n-1]==target: return n-1
    i,j=0,n-1
    while j>i+1:
        mid=(i+j)//2
        if nums[mid]>target: j=mid 
        else: i=mid
    if nums[i]==target: return i
    else: return -1

def solve(nums,target):
    left=search_first(nums,target)
    right=search_last(nums,target,left)
    return [left,right]

print(solve([5,7,7,8,8,10],8))
print(solve([5,7,7,8,8,10],6))
print(solve([],0))

